package com.wuzy.aidlclient.slice;

import com.wuzy.aidlclient.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbilitySlice extends AbilitySlice {
    private static final HiLogLabel TAG = new HiLogLabel(3, 0xD001100, "LocalService");

    @Override
    public void onStart(Intent intent) {
        HiLog.error(TAG, "MainAbilitySlice::onStart");
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        Button botton = (Button)findComponentById(ResourceTable.Id_btn_start_local_service);
        botton.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.wuzy.aidlclient")
                        .withAbilityName("com.wuzy.aidlclient.LocalService")
                        .build();
                intent.setOperation(operation);
                startAbility(intent);
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
